import java.util.Scanner;

public class GuessGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int maxGuesses = 10; // 最大猜测次数
        int numberToGuess = (int) (Math.random() * 100) + 1; // 随机生成1到100之间的数字

        System.out.println("欢迎来到猜数字游戏！");
        System.out.println("我已经想好了一个1到100之间的数字，你有" + maxGuesses + "次机会猜中它。");

        for (int guessesTaken = 1; guessesTaken <= maxGuesses; guessesTaken++) {
            System.out.print("猜一猜: ");
            int guess = scanner.nextInt();

            if (guess == numberToGuess) {
                System.out.println("恭喜你！你猜对了数字是: " + numberToGuess);
                break;
            } else if (guess < numberToGuess) {
                System.out.println("太小了！");
            } else if (guess > numberToGuess) {
                System.out.println("太大了！");
            }

            if (guessesTaken == maxGuesses) {
                System.out.println("很遗憾，你的机会用完了。");
            }

            System.out.print("是否要再玩一次？(yes/no): ");
            String playAgain = scanner.next();
            if (!playAgain.equalsIgnoreCase("yes")) {
                break;
            }

            numberToGuess = (int) (Math.random() * 100) + 1; // 重新开始游戏，生成新的随机数
            System.out.println("游戏重新开始，我已经想好了一个1到100之间的数字。");
        }

        scanner.close();
    }
}